<template>
	<view>
		<cu-custom bgColor="bg-gradual-pink" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">签到</block>
		</cu-custom>
		<view>
			<view class="margin-top-xl maxtop">
				<view class="text-center">
					<button class="round bg-olive xl shadow sign" @click="sign()">
						<view class="margin-top text-xl text-ABC">签到</view>
						<view class="mintop text-xl">{{time}}</view>
					</button>

				</view>
			</view>
		</view>
	</view>

</template>

<script>
	export default {
		data() {
			return {
				time: '',
			}
		},

		onShow() {
			this.getData()
		},
		methods: {
			// 动态时间
			getData() {
				var t = new Date(); //创建一个date的对象，才可以引用相关的date
				var h = t.getHours();
				var m = t.getMinutes();
				var s = t.getSeconds();
				this.time = h + ':' + m + ':' + s;
				let _this = this;
				setTimeout(() => {
					_this.getData();
				}, 1000);
			},
			sign: async function(){
				let that = this;
				let result = await that.$api.personnelsign({});
				if(result.code == 1){
					that.$common.successToShow(result.msg);
				}else{
					that.$common.errorToShow(result.msg);
				}
			}
		}
	}
</script>

<style>
	.sign {
		width: 226upx;
		height: 226upx;
	}

	.maxtop {
		margin-top: 150upx;
	}
	.mintop{
		margin-top: -30upx;
	}
</style>
